package com.xavier.vo;

import cn.hutool.core.util.ObjectUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@Schema(description = "路由出参")
public class RouterVO implements Serializable {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1L;

    @Schema(description = "id")
    private Long id;
    @Schema(description = "父id")
    private Long parentId;
    @Schema(description = "菜单名称")
    private String name;
    @Schema(description = "组件路径")
    private String component;
    @Schema(description = "地址")
    private String path;
    @Schema(description = "设置当前路由高亮的菜单项")
    private String activeMenu;
    @Schema(description = "菜单编码")
    private String menuCode;
    @Schema(description = "排序")
    private Integer sortNumber;
    @Schema(description = "路由显示信息")
    private RouterMetaVO meta;
    @Schema(description = "子路由列表")
    private List<RouterVO> children;

    /**
     * 增加子路由列表
     */
    public void addChildren(RouterVO vo) {
        if (ObjectUtil.isEmpty(children)) {
            children = new ArrayList<>();
        }
        children.add(vo);
    }


}
